<%@ page import="org.ibiblio.terasaur.item.Collection" %>
<%@ page import="org.ibiblio.terasaur.ui.UrlHelper" %>
<%
def urlHelper = new UrlHelper()
%>
<html>
    <head>
        <meta name="layout" content="thin_sidebar" />
        <g:set var="entityName" value="${message(code: 'collection.label', default: 'Collection')}" />
        <content tag="title">List collections</content>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="clear"></div>
        <div class="rule"><hr /></div>

        <div class="body hentry">
            <h2 class="entry-title full-title"><g:message code="default.list.label" args="['Collection']" /></h2>

            <div class="list">
                <table class="download-list" cellspacing="0">
                    <thead>
                        <tr>
                            <g:sortableColumn property="id" title="${message(code: 'collection.id.label', default: 'id')}" />
                            <g:sortableColumn property="name" title="${message(code: 'collection.name.label', default: 'Name')}" />
                            <g:sortableColumn property="owner.username" title="${message(code: 'collection.owner.label', default: 'Owner')}" />
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${collectionInstanceList}" status="i" var="collectionInstance">
                        <g:set var="collectionBrowseLink" value="${urlHelper.collectionLink(collectionInstance, 'show')}" />
                        <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                            <td><a href="${collectionBrowseLink}">${collectionInstance.id}</a></td>
                            <td><a href="${collectionBrowseLink}">${collectionInstance.name}</a></td>
                            <td>${collectionInstance?.owner?.username}</td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${collectionInstanceTotal}" />
            </div>
        </div>
    </body>
</html>
